package com.tingyuge.thinking.spring.configuration.bean.scope.web.contorller;

import com.tingyuge.thinking.spring.ioc.overview.domain.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 * 首页 Spring web mvc controller
 *
 * @author xiaodao
 * @version 1.0
 * @date 2021/7/5
 */
@RequestMapping
@Controller
public class IndexController {

    @Autowired
    private User user;

    /*
    *JSP EL 搜索作用域: page-->request-->session->qpplication(servletContext)
    * */
    @GetMapping("/index.html")
    public String index(Model model) {
        //userObject- 渲染上下文
        //user 对象 servletContext : 上下文名称: user
         model.addAttribute("userObject", user);


        return "index";
    }
}
